<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js编码规范</title>
</head>
<body>
    <div id="articlebody" class="artical"  style="width:61.8%; margin: 0 auto;" data-find="_2">
		<div class="articalTitle"> 
			
								<h2 id="t_69eb015e0100mgr1" class="titName SG_txta">js代码规范</h2>
			
					
							</div>
		
						<!-- 正文开始 -->
		<div id="sina_keyword_ad_area2" class="articalContent   " data-find="_1">
			



<p data-find="_16"><span style="WiDoWs: 2; TexT-TrAnsForM: none; TexT-inDenT: 0px; BorDer-CoLLApse: separate; FonT: medium simsun; WHiTe-spACe: normal; orpHAns: 2; LeTTer-spACinG: normal; CoLor: rgb(0,0,0); WorD-spACinG: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" data-find="_15"><span style="TexT-ALiGn: left; Line-HeiGHT: 18px; FonT-FAMiLY: Tahoma, sans-serif, Helvetica, Tahoma; FonT-siZe: 12px; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px" data-find="_14"><span data-find="_13"><span style="WiDoWs: 2; TexT-TrAnsForM: none; TexT-inDenT: 0px; BorDer-CoLLApse: separate; FonT: medium simsun; WHiTe-spACe: normal; orpHAns: 2; LeTTer-spACinG: normal; CoLor: rgb(0,0,0); WorD-spACinG: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" data-find="_12"><span style="TexT-ALiGn: left; Line-HeiGHT: 18px; FonT-FAMiLY: Tahoma, sans-serif, Helvetica, Tahoma; FonT-siZe: 12px; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px" data-find="_11"><br>

<br>
<font face="Tahoma"><span style="CoLor: blue"><strong style="FonT-WeiGHT: bold">JavaScript文件</strong></span><span>&nbsp;<wbr></span><br>
JavaScript程序应该作为一个.js文件存储和发布。<span>&nbsp;<wbr></span><br>
<br>
JavaScript代码不应该嵌入在HTML文件里，除非那些代码是一个单独的会话特有的。HTML里的JavaScript代码大大增加了页面的大小，并且<span>&nbsp;<wbr></span><br>

很难通过缓存和压缩来缓解。<span>&nbsp;<wbr></span><br>
<br>
&lt;script
src=filename.js&gt;标签应该在body里越靠后的位置越好。这减少了由于加载script而导致的其它页面组件的延迟。</font><strong style="FonT-WeiGHT: bold">没有必要使用<font face="Tahoma"><span>&nbsp;<wbr></span><br>

language或者type属性。由服务器而不是script标签来决定MIME类型。</font></strong><font face="Tahoma"><span>&nbsp;<wbr></span><br>

<br>
<span style="CoLor: blue"><strong style="FonT-WeiGHT: bold">缩进</strong></span><span>&nbsp;<wbr></span><br>
缩进的最小单位是4个空格。不要使用tab键，because (as of this writing in the 21st
Century) there still is not a standard<span>&nbsp;<wbr></span><br>
for the placement of tabstops.
使用空格会引起文件变大，但是这点大小对局域网无关紧要，而且差别被</font><a style="CoLor: rgb(0,102,153); TexT-DeCorATion: underline" href="http://yuiblog.com/blog/2006/03/06/minification-v-obfuscation/" target="_blank">minification</a>消除了。<font face="Tahoma"><span>&nbsp;<wbr></span><br>

<br>
<span style="CoLor: blue"><strong style="FonT-WeiGHT: bold">行宽</strong></span><span>&nbsp;<wbr></span><br>
不要让一行代码超过80个字符。当一条语句不能在单独一行写完时，可能有必要拆分它。在操作符后进行拆分，最好是在逗号后面拆分。<span>&nbsp;<wbr></span><br>

操作符后面进行拆分减少了通过插入分号伪装copy-paste错误的可能性。下一行应该缩进8个空格。<span>&nbsp;<wbr></span><br>
<br>
<span style="CoLor: blue"><strong style="FonT-WeiGHT: bold">注释</strong></span><span>&nbsp;<wbr></span><br>
慷慨的写注释。留下一些供需要理解你做了什么的人们(可能是你自己)下次阅读的信息是有用的。注释应该书写良好和清晰，就像它们<span>&nbsp;<wbr></span><br>

标注的代码一样。偶尔小幽默一把也是可以的。挫折和怨恨就别写了。<span>&nbsp;<wbr></span><br>
<br>
更新注释非常重要。错误的注释让程序更难读懂和理解。<span>&nbsp;<wbr></span><br>
<br>
让注释有意义。更多的关注于不能马上可见的东西。不要用如下内容浪费读者的时间:<span>&nbsp;<wbr></span><br></font></span></span></span></span></span></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=i = 0; // Set i to zero." wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: black">i&nbsp;<wbr>=&nbsp;<wbr></span><span style="CoLor: rgb(192,0,0)">0</span><span style="CoLor: black">;&nbsp;<wbr></span><span style="CoLor: rgb(0,130,0)">//&nbsp;<wbr>Set&nbsp;<wbr>i&nbsp;<wbr>to&nbsp;<wbr>zero.</span><span style="CoLor: black">&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
</ol>
</div>
<p><br>
一般使用行注释。把块注释用于正式文档或外部注释。<font face="Tahoma"><span>&nbsp;<wbr></span><br>
<br>
<span style="CoLor: blue"><strong style="FonT-WeiGHT: bold">变量声明</strong></span><span>&nbsp;<wbr></span><br>
所有的变量应该在使用前声明。JavaScript不强求这点，但是这样做会让程序更易读，并且会让探测未声明的可能变成隐式的</font><a style="CoLor: rgb(0,102,153); TexT-DeCorATion: underline" href="http://yuiblog.com/blog/2006/06/01/global-domination/" target="_blank">globals</a>的<font face="Tahoma"><span>&nbsp;<wbr></span><br>
变量更容易。<span>&nbsp;<wbr></span><br>
<br>
var语句应该为方法体内的第一个语句。<span>&nbsp;<wbr></span><br>
<br>
每个变量声明应该自己占一行并有注释。它们应该按字母顺序排列。<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=var currentEntry; // currentyly selected table entry var level; // indentation level var size; // size of table" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: black">var&nbsp;<wbr>currentEntry;&nbsp;<wbr></span><span style="CoLor: rgb(0,130,0)">//&nbsp;<wbr>currentyly&nbsp;<wbr>selected&nbsp;<wbr>table&nbsp;<wbr>entry</span><span style="CoLor: black">&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">var&nbsp;<wbr>level;&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(0,130,0)">//&nbsp;<wbr>indentation&nbsp;<wbr>level</span><span style="CoLor: black">&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">var&nbsp;<wbr>size;&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(0,130,0)">//&nbsp;<wbr>size&nbsp;<wbr>of&nbsp;<wbr>table</span><span style="CoLor: black">&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
</ol>
</div>
<p><br>
JavaScript没有块作用域，所以在块里定义变量可能会让有其它C家族语言经验的程序员迷惑。在方法顶端定义所有变量。<font face="Tahoma"><span>&nbsp;<wbr></span><br>

<br>
尽量少使用全局变量。隐式的全局变量应该从来不使用。<span>&nbsp;<wbr></span><br>
<br>
<span style="CoLor: blue"><strong style="FonT-WeiGHT: bold">方法声明</strong></span><span>&nbsp;<wbr></span><br>
所有的方法应该在它们使用前声明。内部方法应该位于var语句后面。这让哪些变量包含在它的scope里更清楚。<span>&nbsp;<wbr></span><br>
<br>
方法名和参数列表的“(”(左圆括号)之间不应该有空格。在“)”(右圆括号)和“{”(左大括号)之间有一个空格。<span>&nbsp;<wbr></span><br>
方法体本身缩进4个空格。“}”(右大括号)应该和方法声明处对齐。<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=function outer(c, d) { var e = c * d; function inner(a, b) { return (e * a) + b; } return inner(0, 1); }" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><span style="CoLor: black"><font face="Consolas">function&nbsp;<wbr>outer(c,&nbsp;<wbr>d)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></font></span></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>var&nbsp;<wbr>e&nbsp;<wbr>=&nbsp;<wbr>c&nbsp;<wbr>*&nbsp;<wbr>d;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>function&nbsp;<wbr>inner(a,&nbsp;<wbr>b)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">return</span><span style="CoLor: black">&nbsp;<wbr>(e&nbsp;<wbr>*&nbsp;<wbr>a)&nbsp;<wbr>+&nbsp;<wbr>b;&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">return</span><span style="CoLor: black">&nbsp;<wbr>inner(</span><span style="CoLor: rgb(192,0,0)">0</span><span style="CoLor: black">,&nbsp;<wbr></span><span style="CoLor: rgb(192,0,0)">1</span><span style="CoLor: black">);&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
</ol>
</div>
<p><br>
这个规范可以和JavaScript很好的工作，因为在JavaScript里方法和对象字面量可以放在允许表达式的任何位置。它使用内部方法和复杂<font face="Tahoma"><span>&nbsp;<wbr></span><br>

结构提供最好的可读性。<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=function getElementsByClassName(className) { var results = []; walkTheDOM(document.body, function (node) { var a; // array of class names var c = node.className; // the node's classname var i; // loop counter // If the node has a class name, then split it into a list of simple names. // If any of them match the requested name, then append the node to the set of results. if (c) { a = c.split(' '); for (i = 0; i &lt; a.length; i += 1) { if (a[i] === className) { results.push(node); break; } } } }); return results; }" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><span style="CoLor: black"><font face="Consolas">function&nbsp;<wbr>getElementsByClassName(className)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></font></span></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>var&nbsp;<wbr>results&nbsp;<wbr>=&nbsp;<wbr>[];&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>walkTheDOM(document.body,&nbsp;<wbr>function&nbsp;<wbr>(node)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>var&nbsp;<wbr>a;&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(0,130,0)">//&nbsp;<wbr>array&nbsp;<wbr>of&nbsp;<wbr>class&nbsp;<wbr>names</span><span style="CoLor: black">&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>var&nbsp;<wbr>c&nbsp;<wbr>=&nbsp;<wbr>node.className;&nbsp;<wbr><span style="CoLor: rgb(0,130,0)">//&nbsp;<wbr>the&nbsp;<wbr>node's&nbsp;<wbr>classname</span><span style="CoLor: black">&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>var&nbsp;<wbr>i;&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(0,130,0)">//&nbsp;<wbr>loop&nbsp;<wbr>counter</span><span style="CoLor: black">&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(0,130,0)">//&nbsp;<wbr>If&nbsp;<wbr>the&nbsp;<wbr>node&nbsp;<wbr>has&nbsp;<wbr>a&nbsp;<wbr>class&nbsp;<wbr>name,&nbsp;<wbr>then&nbsp;<wbr>split&nbsp;<wbr>it&nbsp;<wbr>into&nbsp;<wbr>a&nbsp;<wbr>list&nbsp;<wbr>of&nbsp;<wbr>simple&nbsp;<wbr>names.</span><span style="CoLor: black">&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(0,130,0)">//&nbsp;<wbr>If&nbsp;<wbr>any&nbsp;<wbr>of&nbsp;<wbr>them&nbsp;<wbr>match&nbsp;<wbr>the&nbsp;<wbr>requested&nbsp;<wbr>name,&nbsp;<wbr>then&nbsp;<wbr>append&nbsp;<wbr>the&nbsp;<wbr>node&nbsp;<wbr>to&nbsp;<wbr>the&nbsp;<wbr>set&nbsp;<wbr>of&nbsp;<wbr>results.</span><span style="CoLor: black">&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">if</span><span style="CoLor: black">&nbsp;<wbr>(c)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>a&nbsp;<wbr>=&nbsp;<wbr>c.split(<span style="CoLor: blue">'&nbsp;<wbr>'</span><span style="CoLor: black">);&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">for</span><span style="CoLor: black">&nbsp;<wbr>(i&nbsp;<wbr>=&nbsp;<wbr></span><span style="CoLor: rgb(192,0,0)">0</span><span style="CoLor: black">;&nbsp;<wbr>i&nbsp;<wbr>&lt;&nbsp;<wbr>a.length;&nbsp;<wbr>i&nbsp;<wbr>+=&nbsp;<wbr></span><span style="CoLor: rgb(192,0,0)">1</span><span style="CoLor: black">)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">if</span><span style="CoLor: black">&nbsp;<wbr>(a[i]&nbsp;<wbr>===&nbsp;<wbr>className)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>results.push(node);&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">break</span><span style="CoLor: black">;&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>});&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">return</span><span style="CoLor: black">&nbsp;<wbr>results;&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
</ol>
</div>
<p><br>
如果一个方法字面量为匿名的，则在“function”和“(”(左圆括号)之间应该有一个空格。如果省略空格，则它可能看起来方法名是<font face="Tahoma"><span>&nbsp;<wbr></span><br>

“function”，而这是错误的。<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=div.onclick = function (e) { return false; }; that = { method: function () { return this.datum; }, datum: 0; };" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><span style="CoLor: black"><font face="Consolas">div.onclick&nbsp;<wbr>=&nbsp;<wbr>function&nbsp;<wbr>(e)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></font></span></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">return</span><span style="CoLor: black">&nbsp;<wbr></span><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">false</span><span style="CoLor: black">;&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">};&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">that&nbsp;<wbr>=&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>method:&nbsp;<wbr>function&nbsp;<wbr>()&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">return</span><span style="CoLor: black">&nbsp;<wbr></span><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">this</span><span style="CoLor: black">.datum;&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>},&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>datum:&nbsp;<wbr><span style="CoLor: rgb(192,0,0)">0</span><span style="CoLor: black">;&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">};&nbsp;<wbr>&nbsp;<wbr></font></span></li>
</ol>
</div>
<p><br>
尽量少用全局方法。<font face="Tahoma"><span>&nbsp;<wbr></span><br>
<br>
<span style="CoLor: blue"><strong style="FonT-WeiGHT: bold">命名</strong></span><span>&nbsp;<wbr></span><br>
命名应该由26个大小写字母(A .. Z, a .. z)，10个数字(0 ..
9)和_(下划线)组成。不要使用国际字符，因为它们可能不易读或者不能在<span>&nbsp;<wbr></span><br>
任何地方都能容易理解。不要在名字里使用$(美元符号)或\(反斜线符号)。<span>&nbsp;<wbr></span><br>
<br>
不要使用_(下划线)作为名字的首字母。它有时被用来表示私有，但是它实际上不提供私有性。<span>&nbsp;<wbr></span><br>
如果私有性很重要，使用提供私有性的</font><a style="CoLor: rgb(0,102,153); TexT-DeCorATion: underline" href="http://javascript.crockford.com/private.html" target="_blank">private members</a>。<font face="Tahoma"><span>&nbsp;<wbr></span><br>
Avoid conventions that demonstrate a lack of
competence.<span>&nbsp;<wbr></span><br>

<br>
大多数变量和方法名应该以小写字母开始。<span>&nbsp;<wbr></span><br>
<br>
必须使用</font><a style="CoLor: rgb(0,102,153); TexT-DeCorATion: underline" href="http://yuiblog.com/blog/2006/11/13/javascript-we-hardly-new-ya/" target="_blank">new</a>前缀的构造函数应该以大写字母开始。JavaScript不会在省略new时报编译期警告或运行时警告。<font face="Tahoma"><span>&nbsp;<wbr></span><br>

不使用new时会发生坏事情，所以大写首字母规范是我们拥有的唯一的防御。<span>&nbsp;<wbr></span><br>
<br>
全局变量应该全部使用大写字母。(JavaScript没有宏或常量，所以没有多少要求使用大写字母来表示JavaScript的特性的场景)<span>&nbsp;<wbr></span><br>

<br>
<span style="CoLor: blue"><strong style="FonT-WeiGHT: bold">语句</strong></span><span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">简单语句</strong><span>&nbsp;<wbr></span><br>
每行应该包含至少一个语句。在每个简单语句末尾添加一个“;”(分号)。注意一个给方法字面量或对象字面量赋值的赋值语句仍然是<span>&nbsp;<wbr></span><br>

一个赋值语句，所以也必须以分号结尾。<span>&nbsp;<wbr></span><br>
<br>
JavaScript允许任何表达式作为语句使用。这可能产生一些错误，特别是在插入分号时。唯一可以当作语句使用的表达式是赋值表达式和<span>&nbsp;<wbr></span><br>

调用表达式。<span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">复合语句</strong><span>&nbsp;<wbr></span><br>
复合语句是包含一个用“{}”(大括号)包围语句列表的的语句。<span>&nbsp;<wbr></span><br>
1，包围的语句应该再缩进4个空格。<span>&nbsp;<wbr></span><br>
2，“{”(左大括号)应该位于开始复合语句的行的末尾。<span>&nbsp;<wbr></span><br>
3，“}”(右大括号)应该新起一行并且和相匹配的“{”所在那行的起始位置对齐<span>&nbsp;<wbr></span><br>
4，当语句是控制结构的一部分时，所有语句都应该用括号包围，即使是单行语句，例如if或for语句。这让添加语句更容易而且不会引起八哥。<span>&nbsp;<wbr></span><br>

<br>
<strong style="FonT-WeiGHT: bold">标签</strong><span>&nbsp;<wbr></span><br>
语句标签是可选的。只有如下语句需要被标签标识: while，do，for，switch。<span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">return语句</strong><span>&nbsp;<wbr></span><br>
具有值的return语句不应该使用“()”(圆括号)包围值。返回值表达式必须和return关键字在同一行从而避免插入分号。<span>&nbsp;<wbr></span><br>

<br>
<strong style="FonT-WeiGHT: bold">if语句</strong><span>&nbsp;<wbr></span><br>
if语句应该使用如下格式:<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=if (condition) { statements; } if (condition) { statements; } else { statements; } if (condition) { statements; } else if (condition) { statements; } else { statements; }" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">if</span><span style="CoLor: black">&nbsp;<wbr>(condition)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">if</span><span style="CoLor: black">&nbsp;<wbr>(condition)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">else</span><span style="CoLor: black">&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">if</span><span style="CoLor: black">&nbsp;<wbr>(condition)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">else</span><span style="CoLor: black">&nbsp;<wbr></span><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">if</span><span style="CoLor: black">&nbsp;<wbr>(condition)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">else</span><span style="CoLor: black">&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
</ol>
</div>
<p><br>
<br>
<strong style="FonT-WeiGHT: bold">for语句</strong><font face="Tahoma"><span>&nbsp;<wbr></span><br>
for语句应该使用如下格式:<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=for (initialization; condition; update) { statements; } for (variable in object) { statements; }" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">for</span><span style="CoLor: black">&nbsp;<wbr>(initialization;&nbsp;<wbr>condition;&nbsp;<wbr>update)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">for</span><span style="CoLor: black">&nbsp;<wbr>(variable&nbsp;<wbr>in&nbsp;<wbr>object)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
</ol>
</div>
<p><br>
第一种格式应该和数组使用。<font face="Tahoma"><span>&nbsp;<wbr></span><br>
<br>
第二种格式应该和对象使用。注意添加到对象的prototype中的成员将被包含在遍历中。通过使用hasOwnProperty方法来区分对象的<span>&nbsp;<wbr></span><br>

成员是明智的:<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=for (variable in object) { if (object.hasOwnProperty()) { statements; } }" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">for</span><span style="CoLor: black">&nbsp;<wbr>(variable&nbsp;<wbr>in&nbsp;<wbr>object)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">if</span><span style="CoLor: black">&nbsp;<wbr>(object.hasOwnProperty())&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
</ol>
</div>
<p><br>
<br>
<strong style="FonT-WeiGHT: bold">while语句</strong><font face="Tahoma"><span>&nbsp;<wbr></span><br>
while语句应该使用如下格式:<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=while (condition) { statements; }" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">while</span><span style="CoLor: black">&nbsp;<wbr>(condition)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
</ol>
</div>
<p><br>
<br>
<strong style="FonT-WeiGHT: bold">do语句</strong><font face="Tahoma"><span>&nbsp;<wbr></span><br>
do语句应该使用如下格式:<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=do { statements; } while (condition);" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">do</span><span style="CoLor: black">&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">while</span><span style="CoLor: black">&nbsp;<wbr>(condition);&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
</ol>
</div>
<p><br>
不像其它复合语句，do语句始终使用“;”(分号)结尾。<font face="Tahoma"><span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">switch语句</strong><span>&nbsp;<wbr></span><br>
switch语句应该有如下格式:<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">switch</span><span style="CoLor: black">&nbsp;<wbr>(expression)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">case</span><span style="CoLor: black">&nbsp;<wbr>expression:&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">default</span><span style="CoLor: black">:&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
</ol>
</div>
<p><br>
每个case和switch对齐，这避免了缩进过度。<font face="Tahoma"><span>&nbsp;<wbr></span><br>
<br>
每组语句(除了default)应该以break，return或者throw结束。不要fall through。<span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">try语句</strong><span>&nbsp;<wbr></span><br>
try语句应该使用如下格式:<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=try { statements; } catch (variable) { statements; } try { statements; } catch (variable) { statements; } finally { statements; }" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">try</span><span style="CoLor: black">&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">catch</span><span style="CoLor: black">&nbsp;<wbr>(variable)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">try</span><span style="CoLor: black">&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">catch</span><span style="CoLor: black">&nbsp;<wbr>(variable)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">finally</span><span style="CoLor: black">&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>statements;&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">}&nbsp;<wbr>&nbsp;<wbr></font></span></li>
</ol>
</div>
<p><br>
<br>
<strong style="FonT-WeiGHT: bold">continue语句</strong><font face="Tahoma"><span>&nbsp;<wbr></span><br>
不要使用continue语句。它会让方法的控制流程模糊。<span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">with语句</strong><span>&nbsp;<wbr></span><br></font><a style="CoLor: rgb(0,102,153); TexT-DeCorATion: underline" href="http://yuiblog.com/blog/2006/04/11/with-statement-considered-harmful/" target="_blank">不要使用with语句</a>。<font face="Tahoma"><span>&nbsp;<wbr></span><br>
<br>
<span style="CoLor: blue"><strong style="FonT-WeiGHT: bold">空格</strong></span><span>&nbsp;<wbr></span><br>
空行通过将逻辑相关的代码放到一起来增加可读性。<span>&nbsp;<wbr></span><br>
<br>
空格应该用于如下情况:<span>&nbsp;<wbr></span><br>
1，关键字后面跟“(”(左圆括号)时应该用一个空格隔开。<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=while (true) {" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">while</span><span style="CoLor: black">&nbsp;<wbr>(</span><span style="CoLor: rgb(127,0,85); FonT-WeiGHT: bold">true</span><span style="CoLor: black">)&nbsp;<wbr>{&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
</ol>
</div>
<p><br>
2，方法名和方法的“(”(左圆括号)之间不要有空格。这利于区分关键字和方法调用。<font face="Tahoma"><span>&nbsp;<wbr></span><br>
3，所有的二元操作符，除了“.”(圆点)、“(”(左圆括号)和“[”(左中括号)，都应该使用一个空格来和操作数隔开。<span>&nbsp;<wbr></span><br>

4，一元操作符和操作数之间不应该使用空格隔开，除了操作符是一个单词时，如typeof。<span>&nbsp;<wbr></span><br>
5，for语句控制部分的每个“;”(分号)应该在后面跟一个空格。<span>&nbsp;<wbr></span><br>
6，每个“,”(逗号)后面应该跟一个空格。<span>&nbsp;<wbr></span><br>
<br>
<span style="CoLor: blue"><strong style="FonT-WeiGHT: bold">额外的建议</strong></span><span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">{}和[]</strong><span>&nbsp;<wbr></span><br>
使用{}替代new Object()。使用[]替代new Array()。<span>&nbsp;<wbr></span><br>
当成员名字为连续的整数时使用数组。当成员名字为任意的字符串或名字时使用对象。<span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">逗号操作符</strong><span>&nbsp;<wbr></span><br>
不要使用逗号操作符，除了for语句的控制部分的严格使用。(这不适合逗号操作符，它应该用于对象字面量，数组字面量，var语句和参数<span>&nbsp;<wbr></span><br>

列表。)<span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">块作用域</strong><span>&nbsp;<wbr></span><br>
在JavaScript里块没有作用域，只有方法有作用域。不要使用块，除了复合语句一定需要用到外。<span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">赋值表达式</strong><span>&nbsp;<wbr></span><br>
不要在if和while语句的条件部分做赋值。不要写不易懂的代码。<span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">===和!==操作符</strong><span>&nbsp;<wbr></span><br>
始终使用===和!==操作符会更好。==和!=操作符会做类型强制转换。特别是，不要使用==来和“假”值做比较。<span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">令人混淆的加和减</strong><span>&nbsp;<wbr></span><br>
注意不要在“+”后面跟“+”或“++”。这种模式令人混淆。在它们之间插入圆括号来让你的意图更清晰。<span>&nbsp;<wbr></span><br></font></p>
<div style="pADDinG-BoTToM: 1px; oVerFLoW-x: auto; oVerFLoW-Y: auto; BACKGroUnD-CoLor: transparent; pADDinG-LeFT: 1px; WiDTH: 766px; pADDinG-riGHT: 1px; FonT-FAMiLY: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; WorD-WrAp: break-word; MArGin-LeFT: 9px; FonT-siZe: 12px; WorD-BreAK: break-all; pADDinG-Top: 1px">
<div>
<div style="TexT-ALiGn: left; pADDinG-BoTToM: 3px; MArGin: 0px; pADDinG-LeFT: 3px; pADDinG-riGHT: 3px; CoLor: black; FonT-WeiGHT: bold; pADDinG-Top: 3px">Java代码<span>&nbsp;<wbr></span><embed allowscriptaccess="never" allownetworking="internal" autostart="0" height="15" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="14" src="/javascripts/syntaxhighlighter/clipboard_new.swf" quality="high" flashvars="clipboard=total = subtotal + +myInput.value; // is better written as total = subtotal + (+myInput.value);" wmode="transparent"></div>
</div>
<ol style="BorDer-BoTToM: rgb(209,215,220) 1px solid; BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 2px; Line-HeiGHT: 1.4em; BACKGroUnD-CoLor: rgb(255,255,255); LisT-sTYLe-TYpe: decimal; MArGin: 0px 0px 1px; pADDinG-LeFT: 0px; pADDinG-riGHT: 0px; CoLor: rgb(43,145,175); FonT-siZe: 1em; BorDer-Top: rgb(209,215,220) 1px solid; BorDer-riGHT: rgb(209,215,220) 1px solid; pADDinG-Top: 2px">
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><span style="CoLor: black"><font face="Consolas">total&nbsp;<wbr>=&nbsp;<wbr>subtotal&nbsp;<wbr>+&nbsp;<wbr>+myInput.value;&nbsp;<wbr>&nbsp;<wbr></font></span></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas"><span style="CoLor: rgb(0,130,0)">//&nbsp;<wbr>is&nbsp;<wbr>better&nbsp;<wbr>written&nbsp;<wbr>as</span><span style="CoLor: black">&nbsp;<wbr>&nbsp;<wbr></span></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">&nbsp;<wbr>&nbsp;<wbr></font></span></li>
<li style="BorDer-LeFT: rgb(209,215,220) 1px solid; pADDinG-BoTToM: 0px; Line-HeiGHT: 18px; BACKGroUnD-CoLor: rgb(250,250,250); MArGin: 0px 0px 0px 38px; pADDinG-LeFT: 10px; pADDinG-riGHT: 0px; FonT-siZe: 1em; pADDinG-Top: 0px">
<span style="CoLor: black"><font face="Consolas">total&nbsp;<wbr>=&nbsp;<wbr>subtotal&nbsp;<wbr>+&nbsp;<wbr>(+myInput.value);&nbsp;<wbr>&nbsp;<wbr></font></span></li>
</ol>
</div>
<p><br>
这样“+ +”就不会被读错成“++”。<font face="Tahoma"><span>&nbsp;<wbr></span><br>
<br>
<strong style="FonT-WeiGHT: bold">邪恶的eval</strong><span>&nbsp;<wbr></span><br>
eval方法是JavaScript里最滥用的特性。不要使用它。<span>&nbsp;<wbr></span><br>
eval有别名。不要使用Function构造函数。不要传递字符串给setTimeout或者setInterval。</font></p>							
		</div>
						<!-- 正文结束 -->
		
		
		<div class="clearit"></div>
		
		
		<div class="clearit"></div>
							
		<div id="loginFollow"></div>
				
				<div class="clearit"></div>
		
				
		<div class="clearit"></div>
				
	</div>
</body>
</html>